新增店员管理,修复#I1C5AP,#I1C6MK,#I1C055
This commit is contained in:
@ -9,6 +9,7 @@ import lombok.Setter;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
@ -55,4 +56,6 @@ public class YxStoreCategory implements Serializable {
|
||||
public void copy(YxStoreCategory source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package co.yixiang.modules.shop.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-03-22
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="yx_system_store_staff")
|
||||
public class YxSystemStoreStaff implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Integer id;
|
||||
|
||||
/** 微信用户id */
|
||||
@Column(name = "uid",nullable = false)
|
||||
@NotNull(message = "请选择商城会员")
|
||||
private Integer uid;
|
||||
|
||||
/** 店员头像 */
|
||||
@Column(name = "avatar",nullable = false)
|
||||
@NotBlank(message = "请选择商城会员")
|
||||
private String avatar;
|
||||
|
||||
/** 门店id */
|
||||
@Column(name = "store_id",nullable = false)
|
||||
@NotNull
|
||||
private Integer storeId;
|
||||
|
||||
/** 店员名称 */
|
||||
@Column(name = "staff_name",nullable = false)
|
||||
@NotBlank
|
||||
private String staffName;
|
||||
|
||||
/** 手机号码 */
|
||||
@Column(name = "phone",nullable = false)
|
||||
@NotBlank
|
||||
private String phone;
|
||||
|
||||
/** 核销开关 */
|
||||
@Column(name = "verify_status",nullable = false)
|
||||
@NotNull
|
||||
private Integer verifyStatus;
|
||||
|
||||
/** 状态 */
|
||||
@Column(name = "status",insertable = false)
|
||||
private Integer status;
|
||||
|
||||
/** 添加时间 */
|
||||
@Column(name = "add_time")
|
||||
private Integer addTime;
|
||||
|
||||
/** 微信昵称 */
|
||||
@Column(name = "nickname",nullable = false)
|
||||
@NotBlank
|
||||
private String nickname;
|
||||
|
||||
/** 所属门店 */
|
||||
@Column(name = "store_name")
|
||||
private String storeName;
|
||||
|
||||
public void copy(YxSystemStoreStaff source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package co.yixiang.modules.shop.repository;
|
||||
|
||||
import co.yixiang.modules.shop.domain.YxSystemStoreStaff;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-03-22
|
||||
*/
|
||||
public interface YxSystemStoreStaffRepository extends JpaRepository<YxSystemStoreStaff, Integer>, JpaSpecificationExecutor<YxSystemStoreStaff> {
|
||||
}
|
@ -66,6 +66,7 @@ public class StoreCategoryController {
|
||||
if(resources.getPid() > 0 && StrUtil.isBlank(resources.getPic())) {
|
||||
throw new BadRequestException("子分类图片必传");
|
||||
}
|
||||
|
||||
resources.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
return new ResponseEntity(yxStoreCategoryService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
@ -0,0 +1,75 @@
|
||||
package co.yixiang.modules.shop.rest;
|
||||
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.modules.shop.domain.YxSystemStoreStaff;
|
||||
import co.yixiang.modules.shop.service.YxSystemStoreStaffService;
|
||||
import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffQueryCriteria;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-03-22
|
||||
*/
|
||||
@Api(tags = "门店店员管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/yxSystemStoreStaff")
|
||||
public class SystemStoreStaffController {
|
||||
|
||||
private final YxSystemStoreStaffService yxSystemStoreStaffService;
|
||||
|
||||
public SystemStoreStaffController(YxSystemStoreStaffService yxSystemStoreStaffService) {
|
||||
this.yxSystemStoreStaffService = yxSystemStoreStaffService;
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('yxSystemStoreStaff:list')")
|
||||
public void download(HttpServletResponse response, YxSystemStoreStaffQueryCriteria criteria) throws IOException {
|
||||
yxSystemStoreStaffService.download(yxSystemStoreStaffService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询门店店员")
|
||||
@ApiOperation("查询门店店员")
|
||||
@PreAuthorize("@el.check('yxSystemStoreStaff:list')")
|
||||
public ResponseEntity<Object> getYxSystemStoreStaffs(YxSystemStoreStaffQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(yxSystemStoreStaffService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增门店店员")
|
||||
@ApiOperation("新增门店店员")
|
||||
@PreAuthorize("@el.check('yxSystemStoreStaff:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody YxSystemStoreStaff resources){
|
||||
return new ResponseEntity<>(yxSystemStoreStaffService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改门店店员")
|
||||
@ApiOperation("修改门店店员")
|
||||
@PreAuthorize("@el.check('yxSystemStoreStaff:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody YxSystemStoreStaff resources){
|
||||
yxSystemStoreStaffService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除门店店员")
|
||||
@ApiOperation("删除门店店员")
|
||||
@PreAuthorize("@el.check('yxSystemStoreStaff:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> deleteAll(@RequestBody Integer[] ids) {
|
||||
yxSystemStoreStaffService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -51,6 +51,8 @@ public interface YxStoreCategoryService {
|
||||
//@Cacheable(key = "#p0")
|
||||
YxStoreCategoryDTO findById(Integer id);
|
||||
|
||||
YxStoreCategoryDTO findByName(String name);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources
|
||||
|
@ -0,0 +1,66 @@
|
||||
package co.yixiang.modules.shop.service;
|
||||
|
||||
import co.yixiang.modules.shop.domain.YxSystemStoreStaff;
|
||||
import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffDto;
|
||||
import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-03-22
|
||||
*/
|
||||
public interface YxSystemStoreStaffService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(YxSystemStoreStaffQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<YxSystemStoreStaffDto>
|
||||
*/
|
||||
List<YxSystemStoreStaffDto> queryAll(YxSystemStoreStaffQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return YxSystemStoreStaffDto
|
||||
*/
|
||||
YxSystemStoreStaffDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return YxSystemStoreStaffDto
|
||||
*/
|
||||
YxSystemStoreStaffDto create(YxSystemStoreStaff resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(YxSystemStoreStaff resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<YxSystemStoreStaffDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package co.yixiang.modules.shop.service.dto;
|
||||
|
||||
import co.yixiang.modules.shop.domain.YxUser;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -37,6 +38,8 @@ public class YxStoreOrderDTO implements Serializable {
|
||||
// 用户id
|
||||
private Integer uid;
|
||||
|
||||
private YxUserDTO userDTO;
|
||||
|
||||
// 用户姓名
|
||||
private String realName;
|
||||
|
||||
|
@ -0,0 +1,44 @@
|
||||
package co.yixiang.modules.shop.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-03-22
|
||||
*/
|
||||
@Data
|
||||
public class YxSystemStoreStaffDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/** 微信用户id */
|
||||
private Integer uid;
|
||||
|
||||
/** 店员头像 */
|
||||
private String avatar;
|
||||
|
||||
/** 门店id */
|
||||
private Integer storeId;
|
||||
|
||||
/** 店员名称 */
|
||||
private String staffName;
|
||||
|
||||
/** 手机号码 */
|
||||
private String phone;
|
||||
|
||||
/** 核销开关 */
|
||||
private Integer verifyStatus;
|
||||
|
||||
/** 状态 */
|
||||
private Integer status;
|
||||
|
||||
/** 添加时间 */
|
||||
private Integer addTime;
|
||||
|
||||
/** 微信昵称 */
|
||||
private String nickname;
|
||||
|
||||
/** 所属门店 */
|
||||
private String storeName;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package co.yixiang.modules.shop.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import co.yixiang.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-03-22
|
||||
*/
|
||||
@Data
|
||||
public class YxSystemStoreStaffQueryCriteria{
|
||||
|
||||
/** 模糊 */
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String staffName;
|
||||
|
||||
/** 模糊 */
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String nickname;
|
||||
}
|
@ -77,6 +77,11 @@ public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
|
||||
return yxStoreCategoryMapper.toDto(yxStoreCategory.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreCategoryDTO findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public YxStoreCategoryDTO create(YxStoreCategory resources) {
|
||||
@ -88,6 +93,9 @@ public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(YxStoreCategory resources) {
|
||||
if(resources.getId().equals(resources.getPid())){
|
||||
throw new BadRequestException("自己不能选择自己哦");
|
||||
}
|
||||
Optional<YxStoreCategory> optionalYxStoreCategory = yxStoreCategoryRepository.findById(resources.getId());
|
||||
ValidationUtil.isNull( optionalYxStoreCategory,"YxStoreCategory","id",resources.getId());
|
||||
YxStoreCategory yxStoreCategory = optionalYxStoreCategory.get();
|
||||
|
@ -259,6 +259,7 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
cartInfoDTOS.add(cartInfoDTO);
|
||||
}
|
||||
yxStoreOrderDTO.setCartInfoList(cartInfoDTOS);
|
||||
yxStoreOrderDTO.setUserDTO(userService.findById(yxStoreOrder.getUid()));
|
||||
|
||||
storeOrderDTOS.add(yxStoreOrderDTO);
|
||||
|
||||
|
@ -0,0 +1,122 @@
|
||||
package co.yixiang.modules.shop.service.impl;
|
||||
|
||||
import co.yixiang.modules.shop.domain.YxSystemStoreStaff;
|
||||
import co.yixiang.modules.shop.service.YxSystemStoreService;
|
||||
import co.yixiang.modules.shop.service.dto.YxSystemStoreDto;
|
||||
import co.yixiang.utils.*;
|
||||
import co.yixiang.modules.shop.repository.YxSystemStoreStaffRepository;
|
||||
import co.yixiang.modules.shop.service.YxSystemStoreStaffService;
|
||||
import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffDto;
|
||||
import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffQueryCriteria;
|
||||
import co.yixiang.modules.shop.service.mapper.YxSystemStoreStaffMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
// 默认不使用缓存
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-03-22
|
||||
*/
|
||||
@Service
|
||||
//@CacheConfig(cacheNames = "yxSystemStoreStaff")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class YxSystemStoreStaffServiceImpl implements YxSystemStoreStaffService {
|
||||
|
||||
private final YxSystemStoreStaffRepository yxSystemStoreStaffRepository;
|
||||
|
||||
private final YxSystemStoreStaffMapper yxSystemStoreStaffMapper;
|
||||
|
||||
private final YxSystemStoreService systemStoreService;
|
||||
|
||||
public YxSystemStoreStaffServiceImpl(YxSystemStoreStaffRepository yxSystemStoreStaffRepository,
|
||||
YxSystemStoreStaffMapper yxSystemStoreStaffMapper,
|
||||
YxSystemStoreService systemStoreService) {
|
||||
this.yxSystemStoreStaffRepository = yxSystemStoreStaffRepository;
|
||||
this.yxSystemStoreStaffMapper = yxSystemStoreStaffMapper;
|
||||
this.systemStoreService = systemStoreService;
|
||||
}
|
||||
|
||||
@Override
|
||||
//@Cacheable
|
||||
public Map<String,Object> queryAll(YxSystemStoreStaffQueryCriteria criteria, Pageable pageable){
|
||||
Page<YxSystemStoreStaff> page = yxSystemStoreStaffRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(yxSystemStoreStaffMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
//@Cacheable
|
||||
public List<YxSystemStoreStaffDto> queryAll(YxSystemStoreStaffQueryCriteria criteria){
|
||||
return yxSystemStoreStaffMapper.toDto(yxSystemStoreStaffRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
//@Cacheable(key = "#p0")
|
||||
public YxSystemStoreStaffDto findById(Integer id) {
|
||||
YxSystemStoreStaff yxSystemStoreStaff = yxSystemStoreStaffRepository.findById(id).orElseGet(YxSystemStoreStaff::new);
|
||||
ValidationUtil.isNull(yxSystemStoreStaff.getId(),"YxSystemStoreStaff","id",id);
|
||||
return yxSystemStoreStaffMapper.toDto(yxSystemStoreStaff);
|
||||
}
|
||||
|
||||
@Override
|
||||
//@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public YxSystemStoreStaffDto create(YxSystemStoreStaff resources) {
|
||||
YxSystemStoreDto systemStoreDto = systemStoreService.findById(resources.getStoreId());
|
||||
resources.setStoreName(systemStoreDto.getName());
|
||||
resources.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
return yxSystemStoreStaffMapper.toDto(yxSystemStoreStaffRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
//@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(YxSystemStoreStaff resources) {
|
||||
YxSystemStoreDto systemStoreDto = systemStoreService.findById(resources.getStoreId());
|
||||
resources.setStoreName(systemStoreDto.getName());
|
||||
YxSystemStoreStaff yxSystemStoreStaff = yxSystemStoreStaffRepository.findById(resources.getId()).orElseGet(YxSystemStoreStaff::new);
|
||||
ValidationUtil.isNull( yxSystemStoreStaff.getId(),"YxSystemStoreStaff","id",resources.getId());
|
||||
yxSystemStoreStaff.copy(resources);
|
||||
yxSystemStoreStaffRepository.save(yxSystemStoreStaff);
|
||||
}
|
||||
|
||||
@Override
|
||||
//@CacheEvict(allEntries = true)
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
yxSystemStoreStaffRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<YxSystemStoreStaffDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (YxSystemStoreStaffDto yxSystemStoreStaff : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("微信用户id", yxSystemStoreStaff.getUid());
|
||||
map.put("店员头像", yxSystemStoreStaff.getAvatar());
|
||||
map.put("门店id", yxSystemStoreStaff.getStoreId());
|
||||
map.put("店员名称", yxSystemStoreStaff.getStaffName());
|
||||
map.put("手机号码", yxSystemStoreStaff.getPhone());
|
||||
map.put("核销开关", yxSystemStoreStaff.getVerifyStatus());
|
||||
map.put("状态", yxSystemStoreStaff.getStatus());
|
||||
map.put("添加时间", yxSystemStoreStaff.getAddTime());
|
||||
map.put("微信昵称", yxSystemStoreStaff.getNickname());
|
||||
map.put("所属门店", yxSystemStoreStaff.getStoreName());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package co.yixiang.modules.shop.service.mapper;
|
||||
|
||||
import co.yixiang.base.BaseMapper;
|
||||
import co.yixiang.modules.shop.domain.YxSystemStoreStaff;
|
||||
import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-03-22
|
||||
*/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface YxSystemStoreStaffMapper extends BaseMapper<YxSystemStoreStaffDto, YxSystemStoreStaff> {
|
||||
|
||||
}
|
Reference in New Issue
Block a user