提交 c5fe5187 authored 作者: zhouzhigang's avatar zhouzhigang

redis地址变更

上级 02368e6f
package com.zrqx.bg.member.controller.supervise;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageHelper;
import com.zrqx.bg.member.service.supervise.SuperviseService;
import com.zrqx.core.constant.member.MemberRequestPath;
import com.zrqx.core.model.member.school.School;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.enums.resource.diytype.DiyTypeStatusEnum;
import com.zrqx.core.model.member.supervise.Supervise;
import com.zrqx.core.model.resource.diytype.DiyType;
import com.zrqx.core.util.bean.Copy;
import com.zrqx.core.util.datatype.ArrayUtils;
import com.zrqx.core.util.datatype.UUIDUtil;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.core.vo.member.role.RoleMemberVo;
import com.zrqx.core.vo.member.supervise.SuperviseVo;
import com.zrqx.core.vo.resource.bg.diytype.DiyTypeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
@RestController
@RequestMapping(MemberRequestPath.BG + MemberRequestPath.SUPERVISE)
......@@ -29,7 +30,32 @@ public class SuperviseController {
@Autowired
private SuperviseService superviseService;
@ApiOperation(value = "查询全部省监管tree", notes = "查询列表")
@GetMapping(value = ResourceRequestPath.TREE)
public CallBack<List<SuperviseVo>> tree() {
Example example = superviseService.createExample();
example.createCriteria().andEqualTo("status", DiyTypeStatusEnum.STATUS_1.getCode());
PageHelper.orderBy(" createTime desc ");
List<Supervise> list = superviseService.selectByExample(example);
List<SuperviseVo> voList = Copy.copyList(list , SuperviseVo.class, obj -> obj.getParentId().intValue() == 0);
tree(list,voList);
return CallBack.success(voList);
}
public List<SuperviseVo> tree(List<Supervise> list,List<SuperviseVo> voList){
voList.forEach(entity ->{
//第一次设置 一级分类的子类 后续递归设置 子类的子类
entity.setList(Copy.copyList(list, SuperviseVo.class,obj -> obj.getParentId().intValue() == entity.getId().intValue()));
//当前分类存在子类 开始递归子类
if(entity.getList().size() > 0){
tree(list, entity.getList());
}
});
return voList;
}
@ApiOperation(value = "省监管列表", notes = "分页查询省监管列表")
@GetMapping(MemberRequestPath.PAGE)
......@@ -40,6 +66,25 @@ public class SuperviseController {
@ApiOperation(value = "新增", notes = "新增")
@PostMapping(value = MemberRequestPath.SAVE)
public CallBack<Boolean> save(@RequestBody Supervise form) throws Exception{
Example example = superviseService.createExample();
//分页排序查询当前子分类最大code值
example.createCriteria().andEqualTo("parentId", form.getParentId());
PageParam pageParam = new PageParam();
pageParam.setPageSize(1);
pageParam.setOrderBy("code desc");
PageInfo<Supervise> page = superviseService.queryExample(pageParam,example);
if(page.getList() != null && page.getList().size() > 0){
//查询到子分类,获取最大code生成新的code
String code = page.getList().get(0).getCode();
form.setCode(UUIDUtil.newCode(code));
}else{
//没有查询到子分类,获取父类code 拼接 01
if(form.getParentId()!=0){
form.setCode(superviseService.selectByPrimaryKey(form.getParentId()).getCode()+ "01");
}else{
form.setCode("01");
}
}
return superviseService.save(form) ? CallBack.success(true) : CallBack.fail();
}
......
......@@ -65,4 +65,6 @@ public interface SuperviseService extends BaseService<Supervise,Integer>{
*/
Supervise queryInfo(String province);
}
......@@ -3,6 +3,9 @@ package com.zrqx.bg.member.service.supervise;
import java.util.Date;
import java.util.List;
import com.zrqx.core.enums.resource.diytype.DiyTypeStatusEnum;
import com.zrqx.core.model.resource.diytype.DiyType;
import com.zrqx.core.util.datatype.UUIDUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -22,6 +25,7 @@ import com.zrqx.core.service.BaseModelServiceImpl;
import com.zrqx.core.util.encry.MD5Util;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import tk.mybatis.mapper.entity.Example;
@Service
public class SuperviseServiceimpl extends BaseModelServiceImpl<Supervise,Integer> implements SuperviseService{
......@@ -97,7 +101,7 @@ public class SuperviseServiceimpl extends BaseModelServiceImpl<Supervise,Integer
form.setUpdateTime(new Date());
form.setUpdaterName(redis.getOpName());
super.updateByPrimaryKey(form);
//修改经销商的超管信息
//修改省监管的超管信息
memberManage.updateSupervise(form);
return 1;
......@@ -116,8 +120,8 @@ public class SuperviseServiceimpl extends BaseModelServiceImpl<Supervise,Integer
s.setProvince(form.getProvince());
Integer count = superviseMapper.selectCount(s);
if(count > 0){
log.info("SuperviseServiceimpl#isExistName name: "+ form.getProvince() +"省份已存在");
throw new BusinessValidateException("省份: "+ form.getProvince() +"省份已存在");
log.info("SuperviseServiceimpl#isExistName name: "+ form.getProvince() +"已存在");
throw new BusinessValidateException("省份: "+ form.getProvince() +"已存在");
}
return true;
}
......@@ -163,8 +167,7 @@ public class SuperviseServiceimpl extends BaseModelServiceImpl<Supervise,Integer
});
return supervise;
}
}
......@@ -22,8 +22,14 @@ public class Supervise extends BaseModel{
@ApiModelProperty(value = "ID")
private Integer id;
@ApiModelProperty("省份")
@ApiModelProperty("省/市份")
private String province;
@ApiModelProperty(value = "父类id", required = true)
private Integer parentId;
@ApiModelProperty(value = "编号", required = true)
private String code;
@ApiModelProperty("超级管理员用户名")
private String userName;
......
package com.zrqx.core.vo.member.supervise;
import com.zrqx.core.model.member.supervise.Supervise;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel(value = "SuperviseVo", description = "省监管树状列表vo")
public class SuperviseVo extends Supervise {
@ApiModelProperty(value = "子级")
private List<SuperviseVo> list = new ArrayList<SuperviseVo>();
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论