收银后台上传!

This commit is contained in:
liuyingfang
2023-11-13 15:14:09 +08:00
parent 3953b18554
commit 24bcc09bc2
413 changed files with 35183 additions and 27 deletions

View File

@@ -0,0 +1,107 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.member.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author admin
* @date 2022-11-09
**/
@Entity
@Data
@Table(name="c_user")
public class CUser implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "会员id")
private Integer id;
@Column(name = "`user_code`",nullable = false)
@NotBlank
@ApiModelProperty(value = "会员代码")
private String userCode;
@Column(name = "`user_logo`")
@ApiModelProperty(value = "会员logo")
private String userLogo;
@Column(name = "`nicke_name`",nullable = false)
@NotBlank
@ApiModelProperty(value = "会员昵称")
private String nickeName;
@Column(name = "`phone`",nullable = false)
@NotBlank
@ApiModelProperty(value = "电话号码")
private String phone;
@Column(name = "`pwd`",nullable = false)
@NotBlank
@ApiModelProperty(value = "pwd")
private String pwd;
@Column(name = "`salt`")
@ApiModelProperty(value = "加密盐值")
private String salt;
@Column(name = "`status`",nullable = false)
@NotNull
@ApiModelProperty(value = "用户状态")
private Integer status;
@Column(name = "`type`")
@ApiModelProperty(value = "用户类型 ")
private String type;
@Column(name = "`referrer_code`",nullable = false)
@NotBlank
@ApiModelProperty(value = "推荐码")
private String referrerCode;
@Column(name = "`parent_id`",nullable = false)
@NotNull
@ApiModelProperty(value = "parentId")
private Integer parentId;
@Column(name = "`referral_relationship`")
@ApiModelProperty(value = "referralRelationship")
private String referralRelationship;
@Column(name = "`create_time`",nullable = false)
@NotNull
@ApiModelProperty(value = "创建时间")
private Timestamp createTime;
@Column(name = "`update_time`")
@ApiModelProperty(value = "updateTime")
private Timestamp updateTime;
public void copy(CUser source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.member.repository;
import me.zhengjie.modules.member.domain.CUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author admin
* @date 2022-11-09
**/
public interface CUserRepository extends JpaRepository<CUser, Integer>, JpaSpecificationExecutor<CUser> {
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.member.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.member.domain.CUser;
import me.zhengjie.modules.member.service.CUserService;
import me.zhengjie.modules.member.service.dto.CUserQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author admin
* @date 2022-11-09
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "会员管理管理")
@RequestMapping("/api/cUser")
public class CUserController {
private final CUserService cUserService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('cUser:list')")
public void exportCUser(HttpServletResponse response, CUserQueryCriteria criteria) throws IOException {
cUserService.download(cUserService.queryAll(criteria), response);
}
@GetMapping
@Log("查询会员管理")
@ApiOperation("查询会员管理")
@PreAuthorize("@el.check('cUser:list')")
public ResponseEntity<Object> queryCUser(CUserQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(cUserService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增会员管理")
@ApiOperation("新增会员管理")
@PreAuthorize("@el.check('cUser:add')")
public ResponseEntity<Object> createCUser(@Validated @RequestBody CUser resources){
return new ResponseEntity<>(cUserService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改会员管理")
@ApiOperation("修改会员管理")
@PreAuthorize("@el.check('cUser:edit')")
public ResponseEntity<Object> updateCUser(@Validated @RequestBody CUser resources){
cUserService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@Log("删除会员管理")
@ApiOperation("删除会员管理")
@PreAuthorize("@el.check('cUser:del')")
public ResponseEntity<Object> deleteCUser(@RequestBody Integer[] ids) {
cUserService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -0,0 +1,83 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.member.service;
import me.zhengjie.modules.member.domain.CUser;
import me.zhengjie.modules.member.service.dto.CUserDto;
import me.zhengjie.modules.member.service.dto.CUserQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务接口
* @author admin
* @date 2022-11-09
**/
public interface CUserService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(CUserQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<CUserDto>
*/
List<CUserDto> queryAll(CUserQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return CUserDto
*/
CUserDto findById(Integer id);
/**
* 创建
* @param resources /
* @return CUserDto
*/
CUserDto create(CUser resources);
/**
* 编辑
* @param resources /
*/
void update(CUser resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<CUserDto> all, HttpServletResponse response) throws IOException;
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.member.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author admin
* @date 2022-11-09
**/
@Data
public class CUserDto implements Serializable {
/** 会员id */
private Integer id;
/** 会员代码 */
private String userCode;
/** 会员logo */
private String userLogo;
/** 会员昵称 */
private String nickeName;
/** 电话号码 */
private String phone;
private String pwd;
/** 加密盐值 */
private String salt;
/** 用户状态 */
private Integer status;
/** 用户类型 */
private String type;
/** 推荐码 */
private String referrerCode;
private Integer parentId;
private String referralRelationship;
/** 创建时间 */
private Timestamp createTime;
private Timestamp updateTime;
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.member.service.dto;
import lombok.Data;
import java.util.List;
import me.zhengjie.annotation.Query;
/**
* @website https://eladmin.vip
* @author admin
* @date 2022-11-09
**/
@Data
public class CUserQueryCriteria{
/** 精确 */
@Query
private String userCode;
/** 精确 */
@Query
private String nickeName;
/** 精确 */
@Query
private String phone;
/** 精确 */
@Query
private Integer status;
/** 精确 */
@Query
private String type;
}

View File

@@ -0,0 +1,116 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.member.service.impl;
import me.zhengjie.modules.member.domain.CUser;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.member.repository.CUserRepository;
import me.zhengjie.modules.member.service.CUserService;
import me.zhengjie.modules.member.service.dto.CUserDto;
import me.zhengjie.modules.member.service.dto.CUserQueryCriteria;
import me.zhengjie.modules.member.service.mapstruct.CUserMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author admin
* @date 2022-11-09
**/
@Service
@RequiredArgsConstructor
public class CUserServiceImpl implements CUserService {
private final CUserRepository cUserRepository;
private final CUserMapper cUserMapper;
@Override
public Map<String,Object> queryAll(CUserQueryCriteria criteria, Pageable pageable){
Page<CUser> page = cUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(cUserMapper::toDto));
}
@Override
public List<CUserDto> queryAll(CUserQueryCriteria criteria){
return cUserMapper.toDto(cUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public CUserDto findById(Integer id) {
CUser cUser = cUserRepository.findById(id).orElseGet(CUser::new);
ValidationUtil.isNull(cUser.getId(),"CUser","id",id);
return cUserMapper.toDto(cUser);
}
@Override
@Transactional(rollbackFor = Exception.class)
public CUserDto create(CUser resources) {
return cUserMapper.toDto(cUserRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CUser resources) {
CUser cUser = cUserRepository.findById(resources.getId()).orElseGet(CUser::new);
ValidationUtil.isNull( cUser.getId(),"CUser","id",resources.getId());
cUser.copy(resources);
cUserRepository.save(cUser);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer id : ids) {
cUserRepository.deleteById(id);
}
}
@Override
public void download(List<CUserDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (CUserDto cUser : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("会员代码", cUser.getUserCode());
map.put("会员logo", cUser.getUserLogo());
map.put("会员昵称", cUser.getNickeName());
map.put("电话号码", cUser.getPhone());
map.put(" pwd", cUser.getPwd());
map.put("加密盐值", cUser.getSalt());
map.put("用户状态", cUser.getStatus());
map.put("用户类型 ", cUser.getType());
map.put("推荐码", cUser.getReferrerCode());
map.put(" parentId", cUser.getParentId());
map.put(" referralRelationship", cUser.getReferralRelationship());
map.put("创建时间", cUser.getCreateTime());
map.put(" updateTime", cUser.getUpdateTime());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.member.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.member.domain.CUser;
import me.zhengjie.modules.member.service.dto.CUserDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author admin
* @date 2022-11-09
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface CUserMapper extends BaseMapper<CUserDto, CUser> {
}