方药-药列表返回结果修改,增加排序点击量

This commit is contained in:
wuchunlei
2024-01-26 10:16:19 +08:00
parent 928a959998
commit 325dd75bfa
3 changed files with 38 additions and 18 deletions

View File

@@ -36,22 +36,22 @@ public class MedicinalMaterialsController {
@RequestMapping("/getMaterialsList") @RequestMapping("/getMaterialsList")
public R getMaterialsList(@RequestBody Map params){ public R getMaterialsList(@RequestBody Map params){
MPJLambdaWrapper<MedicinalMaterials> wrapper = new MPJLambdaWrapper(); MPJLambdaWrapper<MedicinalMaterials> wrapper = new MPJLambdaWrapper();
if (params.containsKey("name")&&StringUtils.isNotEmpty(params.get("name").toString())){ wrapper.select("id,name,img,latinname,othername,effect,taste,property,tropism,type,sort,hits");
wrapper.and(StringUtils.isNotEmpty(params.get("name").toString()),t->t.like(MedicinalMaterials::getName,params.get("name")).or().like(MedicinalMaterials::getOthername,params.get("name"))); if (StringUtils.isNotEmpty(params.get("name").toString())){
wrapper.and(t->t.like(MedicinalMaterials::getName,params.get("name"))
.or().like(MedicinalMaterials::getOthername,params.get("name")));
} }
if (params.containsKey("type")&&StringUtils.isNotEmpty(params.get("type").toString())){ if (StringUtils.isNotEmpty(params.get("type").toString())){
wrapper.like(MedicinalMaterials::getType,params.get("type")); wrapper.like(MedicinalMaterials::getType,params.get("type"));
} }
if (params.containsKey("taste")&&StringUtils.isNotEmpty(params.get("taste").toString())){ if (StringUtils.isNotEmpty(params.get("effect").toString())){
wrapper.like(MedicinalMaterials::getProperty,params.get("taste")); wrapper.like(MedicinalMaterials::getEffect,params.get("effect"));
}
if (params.containsKey("property")&&StringUtils.isNotEmpty(params.get("property").toString())){
wrapper.like(MedicinalMaterials::getProperty,params.get("property"));
}
if (params.containsKey("tropism")&&StringUtils.isNotEmpty(params.get("tropism").toString())){
wrapper.like(MedicinalMaterials::getProperty,params.get("tropism"));
} }
wrapper.and(t->t.like(MedicinalMaterials::getProperty,params.get("taste"))
.or().like(MedicinalMaterials::getProperty,params.get("property"))
.or().like(MedicinalMaterials::getProperty,params.get("tropism")));
wrapper.orderByAsc(MedicinalMaterials::getSort); wrapper.orderByAsc(MedicinalMaterials::getSort);
wrapper.orderByDesc(MedicinalMaterials::getHits);
Page<MedicinalMaterials> page = materialsService.page(new Page<>( Page<MedicinalMaterials> page = materialsService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper); Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("result", page); return R.ok().put("result", page);
@@ -59,7 +59,11 @@ public class MedicinalMaterialsController {
@RequestMapping(path = "/getMaterials") @RequestMapping(path = "/getMaterials")
public R getMaterials(String id) { public R getMaterials(String id) {
return R.ok().put("result", materialsService.getById(id)); MedicinalMaterials materials = materialsService.getById(id);
int hits = materials.getHits() + 1;
materials.setHits(hits);
materialsService.saveOrUpdate(materials);
return R.ok().put("result", materials);
} }
@RequestMapping(path = "/saveOrUpdateMaterials") @RequestMapping(path = "/saveOrUpdateMaterials")
@@ -81,25 +85,27 @@ public class MedicinalMaterialsController {
@RequestMapping("/getDrugList") @RequestMapping("/getDrugList")
public R getDrugList(@RequestBody Map params){ public R getDrugList(@RequestBody Map params){
MPJLambdaWrapper<MedicinalDrug> wrapper = new MPJLambdaWrapper(); MPJLambdaWrapper<MedicinalDrug> wrapper = new MPJLambdaWrapper();
if (params.containsKey("name")&&StringUtils.isNotEmpty(params.get("name").toString())){ wrapper.select("id,name,english_name,pinyin_name,kind,prescription_type,insurance_type,type,sort,hits");
if (StringUtils.isNotEmpty(params.get("name").toString())){
wrapper.and(StringUtils.isNotEmpty(params.get("name").toString()), wrapper.and(StringUtils.isNotEmpty(params.get("name").toString()),
t->t.like(MedicinalDrug::getName,params.get("name")) t->t.like(MedicinalDrug::getName,params.get("name"))
.or().like(MedicinalDrug::getEnglishName,params.get("name")) .or().like(MedicinalDrug::getEnglishName,params.get("name"))
.or().like(MedicinalDrug::getPinyinName,params.get("name"))); .or().like(MedicinalDrug::getPinyinName,params.get("name")));
} }
if (params.containsKey("kind")&&StringUtils.isNotEmpty(params.get("kind").toString())){ if (StringUtils.isNotEmpty(params.get("kind").toString())){
wrapper.like(MedicinalDrug::getKind,params.get("kind")); wrapper.like(MedicinalDrug::getKind,params.get("kind"));
} }
if (params.containsKey("prescriptionType")&&StringUtils.isNotEmpty(params.get("prescriptionType").toString())){ if (StringUtils.isNotEmpty(params.get("prescriptionType").toString())){
wrapper.like(MedicinalDrug::getPrescriptionType,params.get("prescriptionType")); wrapper.like(MedicinalDrug::getPrescriptionType,params.get("prescriptionType"));
} }
if (params.containsKey("insuranceType")&&StringUtils.isNotEmpty(params.get("insuranceType").toString())){ if (StringUtils.isNotEmpty(params.get("insuranceType").toString())){
wrapper.like(MedicinalDrug::getInsuranceType,params.get("insuranceType")); wrapper.like(MedicinalDrug::getInsuranceType,params.get("insuranceType"));
} }
if (params.containsKey("type")&&StringUtils.isNotEmpty(params.get("type").toString())){ if (StringUtils.isNotEmpty(params.get("type").toString())){
wrapper.like(MedicinalDrug::getType,params.get("type")); wrapper.like(MedicinalDrug::getType,params.get("type"));
} }
wrapper.orderByAsc(MedicinalDrug::getSort); wrapper.orderByAsc(MedicinalDrug::getSort);
wrapper.orderByDesc(MedicinalDrug::getHits);
Page<MedicinalDrug> page = drugService.page(new Page<>( Page<MedicinalDrug> page = drugService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper); Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("result", page); return R.ok().put("result", page);
@@ -107,7 +113,11 @@ public class MedicinalMaterialsController {
@RequestMapping(path = "/getDrug") @RequestMapping(path = "/getDrug")
public R getDrug(String id) { public R getDrug(String id) {
return R.ok().put("result", drugService.getById(id)); MedicinalDrug drug = drugService.getById(id);
int hits = drug.getHits() + 1;
drug.setHits(hits);
drugService.saveOrUpdate(drug);
return R.ok().put("result", drug);
} }
@RequestMapping(path = "/saveOrUpdateDrug") @RequestMapping(path = "/saveOrUpdateDrug")

View File

@@ -63,6 +63,11 @@ public class MedicinalDrug {
*/ */
private Integer sort; private Integer sort;
/**
* 点击量
*/
private Integer hits;
@TableLogic @TableLogic
private Integer delFlag; private Integer delFlag;
} }

View File

@@ -73,6 +73,11 @@ public class MedicinalMaterials {
*/ */
private Integer sort; private Integer sort;
/**
* 点击量
*/
private Integer hits;
@TableLogic @TableLogic
private Integer delFlag; private Integer delFlag;