Commit b1b95d154588379ff35873b40562f502a4797739

Authored by shiyang
1 parent c06bf0a5f6

中医指导文章模块

Showing 5 changed files with 625 additions and 0 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/MedicineArticleService.java View file @ b1b95d1
  1 +package com.lyms.platform.biz.service;
  2 +
  3 +import com.lyms.platform.common.dao.BaseMongoDAOImpl;
  4 +import com.lyms.platform.common.dao.operator.MongoCondition;
  5 +import com.lyms.platform.common.dao.operator.MongoOper;
  6 +import com.lyms.platform.common.dao.operator.MongoQuery;
  7 +import com.lyms.platform.common.enums.YnEnums;
  8 +import com.lyms.platform.pojo.BabyOralCheck;
  9 +import com.lyms.platform.pojo.LhBabyEyeCheck;
  10 +import com.lyms.platform.pojo.MedicineArticleModel;
  11 +import com.lyms.platform.query.BabyOralCheckQuery;
  12 +import com.lyms.platform.query.LhBabyEyelCheckQuery;
  13 +import com.lyms.platform.query.MedicineArticleQuery;
  14 +import org.apache.commons.lang.ArrayUtils;
  15 +import org.apache.commons.lang.StringUtils;
  16 +import org.springframework.data.domain.Sort;
  17 +import org.springframework.stereotype.Service;
  18 +
  19 +import java.util.Date;
  20 +import java.util.List;
  21 +
  22 +/**
  23 + * Created by shy on 2022/3/17.
  24 + * 中医指导文章 逻辑
  25 + */
  26 +
  27 +@Service("MedicineArticleService")
  28 +public class MedicineArticleService extends BaseMongoDAOImpl<MedicineArticleModel> {
  29 +
  30 + /**
  31 + * 新增
  32 + * @param model
  33 + * @return
  34 + */
  35 + public MedicineArticleModel add(MedicineArticleModel model) {
  36 + model.setCreated(new Date());
  37 + model.setYn(YnEnums.YES.getId());
  38 + mongoTemplate.insert(model);
  39 + return model;
  40 + }
  41 +
  42 + /**
  43 + * 根据id修改
  44 + * @param model
  45 + */
  46 + public void update(MedicineArticleModel model) {
  47 + model.setModified(new Date());
  48 + update(new MongoQuery(new MongoCondition("id", model.getId(), MongoOper.IS)).convertToMongoQuery(), model);
  49 + }
  50 +
  51 + /**
  52 + * 删除
  53 + * @param id
  54 + */
  55 + public void deleteById(String id) {
  56 + MedicineArticleModel obj = new MedicineArticleModel();
  57 + obj.setYn(YnEnums.NO.getId());
  58 + obj.setId(id);
  59 + update(new MongoQuery(new MongoCondition("id", id, MongoOper.IS)).convertToMongoQuery(), obj);
  60 + }
  61 +
  62 + /**
  63 + * 根据id查询
  64 + * @param id
  65 + * @return
  66 + */
  67 + public MedicineArticleModel queryById(String id) {
  68 + MedicineArticleQuery modelQuery = new MedicineArticleQuery();
  69 + modelQuery.setId(id);
  70 + MongoQuery query = modelQuery.convertToQuery();
  71 + return findOne(query.convertToMongoQuery());
  72 + }
  73 +
  74 + /**
  75 + * 根据条件查询
  76 + * @param modelQuery 查询条件
  77 + * @param sortkeys 按什么字段排序(如null必须sort也为null表示不排序)
  78 + * @param sort 排序 ASC/DESC
  79 + * Need 给这个字段赋值代表需要分页,null不需要分页
  80 + * @return
  81 + */
  82 + public List<MedicineArticleModel> queryList(MedicineArticleQuery modelQuery, Sort.Direction sort, String[] sortkeys) {
  83 + MongoQuery query = modelQuery.convertToQuery();
  84 + if (StringUtils.isNotEmpty(modelQuery.getNeed())) {//是否需要分页
  85 + modelQuery.mysqlBuild((int)count(modelQuery.convertToQuery().convertToMongoQuery()));
  86 + query.start(modelQuery.getOffset()).end(modelQuery.getLimit());
  87 + }
  88 + if(ArrayUtils.isNotEmpty(sortkeys) && null!=sort){
  89 + for (String sortkey : sortkeys) {
  90 + query.addOrder(sort, sortkey);
  91 + }
  92 + }
  93 + return find(query.convertToMongoQuery());
  94 + }
  95 +
  96 +
  97 +
  98 +}
platform-dal/src/main/java/com/lyms/platform/pojo/MedicineArticleModel.java View file @ b1b95d1
  1 +package com.lyms.platform.pojo;
  2 +
  3 +import com.lyms.platform.common.result.BaseModel;
  4 +import org.springframework.data.mongodb.core.mapping.Document;
  5 +
  6 +import java.util.Date;
  7 +
  8 +
  9 +/**
  10 + * 中医指导文章
  11 + *
  12 + * @author Administrator
  13 + */
  14 +@Document(collection = "lyms_medicineArticle")
  15 +public class MedicineArticleModel extends BaseModel {
  16 + /**
  17 + * id
  18 + */
  19 + private String id;
  20 + /**
  21 + * 数据 1: "有效",0: "无效"
  22 + */
  23 + private Integer yn;
  24 + /**
  25 + * 系统创建时间
  26 + */
  27 + private Date created;
  28 + /**
  29 + * 系统修改时间
  30 + */
  31 + private Date modified;
  32 + /**
  33 + * 医院机构
  34 + */
  35 + private String hospitalId;
  36 + /**
  37 + * 文章标题
  38 + */
  39 + private String title;
  40 + /**
  41 + * 文章类型
  42 + */
  43 + private Integer type;
  44 + /**
  45 + * 文章内容
  46 + */
  47 + private String contents;
  48 + /**
  49 + * 短文字
  50 + */
  51 + private String shortText;
  52 + /**
  53 + * 月龄范围开始
  54 + */
  55 + private Integer monthAgeStart;
  56 + /**
  57 + * 月龄范围结束
  58 + */
  59 + private Integer monthAgeEnd;
  60 +
  61 +
  62 + public String getId() {
  63 + return id;
  64 + }
  65 +
  66 + public void setId(String id) {
  67 + this.id = id;
  68 + }
  69 +
  70 +
  71 + public Date getCreated() {
  72 + return created;
  73 + }
  74 +
  75 + public void setCreated(Date created) {
  76 + this.created = created;
  77 + }
  78 +
  79 + public Date getModified() {
  80 + return modified;
  81 + }
  82 +
  83 + public void setModified(Date modified) {
  84 + this.modified = modified;
  85 + }
  86 +
  87 + public String getTitle() {
  88 + return title;
  89 + }
  90 +
  91 + public void setTitle(String title) {
  92 + this.title = title;
  93 + }
  94 +
  95 +
  96 + public String getContents() {
  97 + return contents;
  98 + }
  99 +
  100 + public void setContents(String contents) {
  101 + this.contents = contents;
  102 + }
  103 +
  104 + public String getShortText() {
  105 + return shortText;
  106 + }
  107 +
  108 + public void setShortText(String shortText) {
  109 + this.shortText = shortText;
  110 + }
  111 +
  112 +
  113 + public String getHospitalId() {
  114 + return hospitalId;
  115 + }
  116 +
  117 + public void setHospitalId(String hospitalId) {
  118 + this.hospitalId = hospitalId;
  119 + }
  120 +
  121 + public Integer getYn() {
  122 + return yn;
  123 + }
  124 +
  125 + public void setYn(Integer yn) {
  126 + this.yn = yn;
  127 + }
  128 +
  129 + public Integer getType() {
  130 + return type;
  131 + }
  132 +
  133 + public void setType(Integer type) {
  134 + this.type = type;
  135 + }
  136 +
  137 + public Integer getMonthAgeStart() {
  138 + return monthAgeStart;
  139 + }
  140 +
  141 + public void setMonthAgeStart(Integer monthAgeStart) {
  142 + this.monthAgeStart = monthAgeStart;
  143 + }
  144 +
  145 + public Integer getMonthAgeEnd() {
  146 + return monthAgeEnd;
  147 + }
  148 +
  149 + public void setMonthAgeEnd(Integer monthAgeEnd) {
  150 + this.monthAgeEnd = monthAgeEnd;
  151 + }
  152 +}
platform-dal/src/main/java/com/lyms/platform/query/MedicineArticleQuery.java View file @ b1b95d1
  1 +package com.lyms.platform.query;
  2 +
  3 +import com.lyms.platform.common.base.IConvertToNativeQuery;
  4 +import com.lyms.platform.common.dao.BaseQuery;
  5 +import com.lyms.platform.common.dao.operator.MongoCondition;
  6 +import com.lyms.platform.common.dao.operator.MongoOper;
  7 +import com.lyms.platform.common.dao.operator.MongoQuery;
  8 +import com.lyms.platform.common.utils.StringUtils;
  9 +import org.apache.commons.collections.CollectionUtils;
  10 +import org.springframework.data.mongodb.core.query.Criteria;
  11 +
  12 +import java.util.Date;
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * 中医指导文章-查询
  17 + * <p>
  18 + * Created by Administrator on 2022/3/31 .
  19 + */
  20 +public class MedicineArticleQuery extends BaseQuery implements IConvertToNativeQuery {
  21 + /**
  22 + * id
  23 + */
  24 + private String id;
  25 + /**
  26 + * 数据 1: "有效",0: "无效"
  27 + */
  28 + private Integer yn;
  29 + /**
  30 + * 系统创建时间-开始
  31 + */
  32 + private Date createdStart;
  33 + /**
  34 + * 系统创建时间-结束
  35 + */
  36 + private Date createdEnd;
  37 +
  38 + /**
  39 + * 医院机构
  40 + */
  41 + private String hospitalId;
  42 + /**
  43 + * 文章标题
  44 + */
  45 + private String title;
  46 + /**
  47 + * 文章类型
  48 + */
  49 + private Integer type;
  50 +
  51 + /**
  52 + * 月龄范围开始
  53 + */
  54 + private Integer monthAgeStart;
  55 + /**
  56 + * 月龄范围结束
  57 + */
  58 + private Integer monthAgeEnd;
  59 + @Override
  60 + public MongoQuery convertToQuery() {
  61 + MongoCondition condition = MongoCondition.newInstance();
  62 + if (StringUtils.isNotEmpty( id)) {
  63 + condition = condition.and("id", id, MongoOper.IS);
  64 + }
  65 + if (null != yn) {
  66 + condition = condition.and("yn", yn, MongoOper.IS);
  67 + }
  68 +
  69 + if (StringUtils.isNotEmpty(hospitalId)) {
  70 + condition = condition.and("hospitalId", hospitalId, MongoOper.IS);
  71 + }
  72 + if (null != type) {
  73 + condition = condition.and("type", type, MongoOper.IS);
  74 + }
  75 + if (StringUtils.isNotEmpty( title)) {
  76 + condition = condition.and("title", title, MongoOper.LIKE);
  77 + }
  78 + if (null != monthAgeStart) {
  79 + condition = condition.and("monthAgeStart", monthAgeStart, MongoOper.IS);
  80 + }
  81 + if (null != monthAgeEnd) {
  82 + condition = condition.and("monthAgeEnd", monthAgeEnd, MongoOper.IS);
  83 + }
  84 +
  85 + Criteria c = null;
  86 +
  87 + if (null != createdStart && createdEnd != null) {
  88 + if (null != c) {
  89 + c = c.and("created").gte(createdStart).lte(createdEnd);
  90 + } else {
  91 + c = Criteria.where("created").gte(createdStart).lte(createdEnd);
  92 + }
  93 + }
  94 +
  95 +
  96 + if (null != c) {
  97 + return new MongoCondition(c.andOperator(condition.getCriteria())).toMongoQuery();
  98 + }
  99 + return condition.toMongoQuery();
  100 + }
  101 +
  102 + public String getId() {
  103 + return id;
  104 + }
  105 +
  106 + public void setId(String id) {
  107 + this.id = id;
  108 + }
  109 +
  110 + public Integer getYn() {
  111 + return yn;
  112 + }
  113 +
  114 + public void setYn(Integer yn) {
  115 + this.yn = yn;
  116 + }
  117 +
  118 + public Date getCreatedStart() {
  119 + return createdStart;
  120 + }
  121 +
  122 + public void setCreatedStart(Date createdStart) {
  123 + this.createdStart = createdStart;
  124 + }
  125 +
  126 + public Date getCreatedEnd() {
  127 + return createdEnd;
  128 + }
  129 +
  130 + public void setCreatedEnd(Date createdEnd) {
  131 + this.createdEnd = createdEnd;
  132 + }
  133 +
  134 + public String getHospitalId() {
  135 + return hospitalId;
  136 + }
  137 +
  138 + public void setHospitalId(String hospitalId) {
  139 + this.hospitalId = hospitalId;
  140 + }
  141 +
  142 + public String getTitle() {
  143 + return title;
  144 + }
  145 +
  146 + public void setTitle(String title) {
  147 + this.title = title;
  148 + }
  149 +
  150 + public Integer getType() {
  151 + return type;
  152 + }
  153 +
  154 + public void setType(Integer type) {
  155 + this.type = type;
  156 + }
  157 +
  158 + public Integer getMonthAgeStart() {
  159 + return monthAgeStart;
  160 + }
  161 +
  162 + public void setMonthAgeStart(Integer monthAgeStart) {
  163 + this.monthAgeStart = monthAgeStart;
  164 + }
  165 +
  166 + public Integer getMonthAgeEnd() {
  167 + return monthAgeEnd;
  168 + }
  169 +
  170 + public void setMonthAgeEnd(Integer monthAgeEnd) {
  171 + this.monthAgeEnd = monthAgeEnd;
  172 + }
  173 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MedicineArticleController.java View file @ b1b95d1
  1 +package com.lyms.platform.operate.web.controller;
  2 +
  3 +import com.lyms.platform.common.annotation.TokenRequired;
  4 +import com.lyms.platform.common.base.BaseController;
  5 +import com.lyms.platform.common.base.LoginContext;
  6 +import com.lyms.platform.common.result.BaseResponse;
  7 +import com.lyms.platform.operate.web.facade.LhBabyEyeCheckFacade;
  8 +import com.lyms.platform.operate.web.facade.MedicineArticleFacade;
  9 +import com.lyms.platform.pojo.LhBabyEyeCheck;
  10 +import com.lyms.platform.pojo.MedicineArticleModel;
  11 +import com.lyms.platform.query.BabyModelQuery;
  12 +import com.lyms.platform.query.LhBabyEyelCheckQuery;
  13 +import com.lyms.platform.query.MedicineArticleQuery;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.stereotype.Controller;
  16 +import org.springframework.web.bind.annotation.*;
  17 +
  18 +import javax.servlet.http.HttpServletRequest;
  19 +
  20 +
  21 +/**
  22 + * 中医指导文章
  23 + * Created by Administrator on 2022/3/31.
  24 + *
  25 + */
  26 +
  27 +@Controller
  28 +@RequestMapping("/medicineArticle")
  29 +public class MedicineArticleController extends BaseController {
  30 +
  31 + @Autowired
  32 + private MedicineArticleFacade medicineArticleFacade;
  33 +
  34 +
  35 +
  36 + /**
  37 + * 中医指导文章-添加、编辑
  38 + * @param model
  39 + * @return
  40 + */
  41 + @RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST)
  42 + @ResponseBody
  43 + public BaseResponse addOrUpdate(@RequestBody MedicineArticleModel model, HttpServletRequest request){
  44 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  45 + return medicineArticleFacade.addOrUpdate(model,loginState.getId());
  46 + }
  47 +
  48 + /**
  49 + * 中医指导文章-删除
  50 + * @param id
  51 + * @return
  52 + */
  53 + @RequestMapping(value = "/delData", method = RequestMethod.DELETE)
  54 + @ResponseBody
  55 + public BaseResponse delData(String id, HttpServletRequest request){
  56 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  57 + return medicineArticleFacade.delData(id,loginState.getId());
  58 + }
  59 + /**
  60 + * 编辑时回显数据
  61 + * @param id
  62 + * @return
  63 + */
  64 + @ResponseBody
  65 + @TokenRequired
  66 + @RequestMapping(value = "/queryUpDate",method = RequestMethod.GET)
  67 + public BaseResponse queryUpDate(String id) {
  68 +
  69 + return medicineArticleFacade.queryUpDate(id);
  70 + }
  71 +
  72 + /**
  73 + * 文章列表列表
  74 + * @param modelQuery
  75 + * @param request
  76 + * @return
  77 + */
  78 + @ResponseBody
  79 + @TokenRequired
  80 + @RequestMapping(value = "/queryListPage",method = RequestMethod.GET)
  81 + public BaseResponse queryListPage(MedicineArticleQuery modelQuery, HttpServletRequest request) {
  82 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  83 + return medicineArticleFacade.queryListPage(modelQuery,loginState.getId());
  84 + }
  85 +
  86 +
  87 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MedicineArticleFacade.java View file @ b1b95d1
  1 +package com.lyms.platform.operate.web.facade;
  2 +
  3 +import com.lyms.platform.biz.service.BabyBookbuildingService;
  4 +import com.lyms.platform.biz.service.MedicineArticleService;
  5 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  6 +import com.lyms.platform.common.enums.OptActionEnums;
  7 +import com.lyms.platform.common.enums.YnEnums;
  8 +import com.lyms.platform.common.result.BaseObjectResponse;
  9 +import com.lyms.platform.common.result.BaseResponse;
  10 +import com.lyms.platform.common.utils.DateUtil;
  11 +import com.lyms.platform.common.utils.ReflectionUtils;
  12 +import com.lyms.platform.common.utils.StringUtils;
  13 +import com.lyms.platform.permission.dao.master.CouponMapper;
  14 +import com.lyms.platform.permission.service.OrganizationService;
  15 +import com.lyms.platform.pojo.MedicineArticleModel;
  16 +import com.lyms.platform.query.MedicineArticleQuery;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.data.domain.Sort;
  19 +import org.springframework.data.mongodb.core.MongoTemplate;
  20 +import org.springframework.stereotype.Component;
  21 +
  22 +import java.util.ArrayList;
  23 +import java.util.List;
  24 +import java.util.Map;
  25 +
  26 +/**
  27 + *
  28 + * Created by shy on 2022/3/31.
  29 + * 中医指导文章 业务处理
  30 + *
  31 + */
  32 +@Component
  33 +public class MedicineArticleFacade {
  34 + @Autowired
  35 + private AutoMatchFacade autoMatchFacade;
  36 + @Autowired
  37 + private MongoTemplate mongoTemplate;
  38 + @Autowired
  39 + private OrganizationService organizationService;
  40 + @Autowired
  41 + private CouponMapper couponMapper;
  42 + @Autowired
  43 + private OperateLogFacade operateLogFacade;
  44 + @Autowired
  45 + private MedicineArticleService medicineArticleService;
  46 +
  47 +
  48 +
  49 + public BaseResponse addOrUpdate(MedicineArticleModel model,Integer userid) {
  50 + String hospitalId = autoMatchFacade.getHospitalId(userid);
  51 + model.setHospitalId(hospitalId);
  52 + //添加
  53 + if(StringUtils.isEmpty(model.getId())){
  54 + medicineArticleService.add(model);
  55 + operateLogFacade.addDeleteOptLog(userid, Integer.parseInt(hospitalId), model, OptActionEnums.ADD.getId(), "添加中医指导文章");
  56 +
  57 + }else{//修改
  58 + medicineArticleService.update(model);
  59 + MedicineArticleModel model2 = medicineArticleService.queryById(model.getId());
  60 + if (null!=model2) {
  61 + operateLogFacade.addDeleteOptLog(userid, Integer.parseInt(hospitalId), model2, OptActionEnums.UPDATE.getId(), "修改中医指导文章");
  62 + }
  63 + }
  64 + BaseObjectResponse br = new BaseObjectResponse();
  65 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  66 + br.setErrormsg("成功");
  67 + br.setData(model.getId());
  68 + return br;
  69 + }
  70 +
  71 + public BaseResponse delData(String id,Integer userid) {
  72 + String hospitalId = autoMatchFacade.getHospitalId(userid);
  73 + medicineArticleService.deleteById(id);
  74 + MedicineArticleModel model = medicineArticleService.queryById(id);
  75 + if (null!=model) {
  76 + operateLogFacade.addDeleteOptLog(userid, Integer.parseInt(hospitalId), model, OptActionEnums.DELETE.getId(), "删除中医指导文章");
  77 + }
  78 + BaseObjectResponse br = new BaseObjectResponse();
  79 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  80 + br.setErrormsg("成功");
  81 + return br;
  82 + }
  83 + public BaseResponse queryUpDate(String id) {
  84 + MedicineArticleModel model = medicineArticleService.queryById(id);
  85 + BaseObjectResponse br = new BaseObjectResponse();
  86 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  87 + br.setData(model);
  88 + br.setErrormsg("成功");
  89 + return br;
  90 + }
  91 +
  92 + public BaseResponse queryListPage(MedicineArticleQuery request, Integer userid) {
  93 + String hospitalId = autoMatchFacade.getHospitalId(userid);
  94 + request.setHospitalId(hospitalId);
  95 + request.setYn(YnEnums.YES.getId());
  96 + request.setNeed("true");
  97 + if (request.getCreatedEnd() != null) {
  98 + request.setCreatedEnd(DateUtil.getDayLastSecond(request.getCreatedEnd()));
  99 + }
  100 + List<MedicineArticleModel> resultList=medicineArticleService.queryList(request, Sort.Direction.DESC,new String[]{"created"});
  101 + List<Map> result=new ArrayList<>();
  102 + for (MedicineArticleModel model : resultList) {
  103 + Map<String,Object> map= ReflectionUtils.beanToMap(model);//对象转map
  104 + map.put("hospitalName",couponMapper.getHospitalName(hospitalId));
  105 + result.add(map);
  106 + }
  107 +
  108 + BaseObjectResponse br = new BaseObjectResponse();
  109 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  110 + br.setData(result);
  111 + br.setPageInfo(request.getPageInfo());
  112 + br.setErrormsg("成功");
  113 + return br;
  114 + }
  115 +}