diff --git a/src/main/java/io/v/nutz/zhgh/activity/controller/basic/ActivityBasicScopeController.java b/src/main/java/io/v/nutz/zhgh/activity/controller/basic/ActivityBasicScopeController.java index fbbad82..977301a 100644 --- a/src/main/java/io/v/nutz/zhgh/activity/controller/basic/ActivityBasicScopeController.java +++ b/src/main/java/io/v/nutz/zhgh/activity/controller/basic/ActivityBasicScopeController.java @@ -284,7 +284,7 @@ public class ActivityBasicScopeController { addv("is_H04", ShiroUtil.hasRole("H04")); addv("is_H02", ShiroUtil.hasRole("club01")); addv("is_H03", ShiroUtil.hasRole("SchoolUnionMemberAdmin")); - addv("is_sysadmin", ShiroUtil.hasRole("sysadmin,SCHOOL_UNION_SPORTS_ADMIN")); + addv("is_sysadmin", ShiroUtil.hasAnyRoles("sysadmin,SCHOOL_UNION_SPORTS_ADMIN")); addv("unionid", Vi.getUnionId()); }}; } diff --git a/src/main/java/io/v/nutz/zhgh/healthCheckup/controller/HealthCheckupListController.java b/src/main/java/io/v/nutz/zhgh/healthCheckup/controller/HealthCheckupListController.java index bf5b17e..655a03a 100644 --- a/src/main/java/io/v/nutz/zhgh/healthCheckup/controller/HealthCheckupListController.java +++ b/src/main/java/io/v/nutz/zhgh/healthCheckup/controller/HealthCheckupListController.java @@ -3,13 +3,14 @@ package io.v.nutz.zhgh.healthCheckup.controller; import cn.hutool.core.util.StrUtil; import cn.wizzer.framework.page.Pagination; import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.query.PageForm; +import io.v.nutz.base.result.Result; import io.v.nutz.base.utils.Vi; import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupProject; import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupProjectSubject; import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupUserSelection; import io.v.nutz.zhgh.healthCheckup.service.HealthCheckupProjectService; -import io.v.nutz.base.query.PageForm; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.nutz.aop.interceptor.ioc.TransAop; import org.nutz.dao.Cnd; @@ -117,28 +118,53 @@ public class HealthCheckupListController { @ViReturn @Aop(TransAop.READ_COMMITTED) @RequiresPermissions("healthCheckup.list.mange") - public Object doEditHealthCheckupData(String subjectId, String campus, String projectId, String userId) { - + public Object doEditHealthCheckupData(HealthCheckupUserSelection selection) { + if (Lang.isEmpty(selection)) { + return Result.error("数据传递异常"); + } + if (Lang.isEmpty(selection.getSelectUserId())) { + return Result.error("请选择用户"); + } //查询用户有没有选择过套餐 HealthCheckupUserSelection userSelection = healthCheckupProjectService.dao().fetch(HealthCheckupUserSelection.class, - Cnd.where("projectId", "=", projectId).and("selectUserId", "=", userId)); + Cnd.where("projectId", "=", selection.getProjectId()).and("selectUserId", "=", selection.getSelectUserId())); //如果选择过套餐就修改选择的套餐id if (Lang.isNotEmpty(userSelection)) { - userSelection.setSubjectId(subjectId); - userSelection.setCampus(campus); - healthCheckupProjectService.update(userSelection); - } else { - //如果没有选择过套餐添加一条记录 - HealthCheckupUserSelection checkupUserSelection = new HealthCheckupUserSelection(); - checkupUserSelection.setSelectUserId(userId); - checkupUserSelection.setProjectId(projectId); - checkupUserSelection.setSubjectId(subjectId); - checkupUserSelection.setCampus(campus); - checkupUserSelection.setSelectTime(new Date()); - healthCheckupProjectService.insert(checkupUserSelection); + selection.setId(userSelection.getId()); } + selection.setSelectTime(new Date()); + healthCheckupProjectService.dao().insertOrUpdate(selection); return null; } + @At + @ViReturn + @RequiresPermissions("healthCheckup.list.mange") + public Object getHealthEditData(String userId, String projectId){ + // 先去查询有没有选择,选择了直接返回数据 + HealthCheckupUserSelection userSelection = healthCheckupProjectService.dao().fetch(HealthCheckupUserSelection.class, + Cnd.where("projectId", "=", projectId).and("selectUserId", "=", userId)); + // 没有选择去查询基本信息 + if (Lang.isNotEmpty(userSelection)) { + return userSelection; + } else { + Sql sql = Sqls.create(""" + SELECT + id, + loginname, + username, + sex, + mobile, + idcard, + TIMESTAMPDIFF(YEAR, STR_TO_DATE(SUBSTRING(idcard, 7, 8), '%Y%m%d'), CURDATE()) AS age + FROM + sys_user + WHERE id = @userId + """).setParam("userId", userId); + sql.setCallback(Sqls.callback.map()); + healthCheckupProjectService.dao().execute(sql); + return sql.getResult(); + } + } } diff --git a/src/main/java/io/v/nutz/zhgh/healthCheckup/model/HealthCheckupUserSelection.java b/src/main/java/io/v/nutz/zhgh/healthCheckup/model/HealthCheckupUserSelection.java index 913b1a5..ae456bc 100644 --- a/src/main/java/io/v/nutz/zhgh/healthCheckup/model/HealthCheckupUserSelection.java +++ b/src/main/java/io/v/nutz/zhgh/healthCheckup/model/HealthCheckupUserSelection.java @@ -43,6 +43,31 @@ public class HealthCheckupUserSelection { @ColDefine(type = ColType.VARCHAR, width = 32) private String campus; + @Column + @Comment("用户名") + @ColDefine(type = ColType.VARCHAR, width = 50) + private String username; + + @Column + @Comment("性别") + @ColDefine(type = ColType.VARCHAR, width = 32) + private String sex; + + @Column + @Comment("年龄") + @ColDefine(type = ColType.INT) + private Integer age; + + @Column + @Comment("身份证号") + @ColDefine(type = ColType.VARCHAR, width = 18) + private String idcard; + + @Column + @Comment("联系方式") + @ColDefine(type = ColType.VARCHAR, width = 20) + private String mobile; + @Column @Comment("选择时间") @ColDefine(type = ColType.DATETIME) diff --git a/src/main/java/io/v/nutz/zhgh/mobile/healthCheckup/MHealthCheckupListController.java b/src/main/java/io/v/nutz/zhgh/mobile/healthCheckup/MHealthCheckupListController.java index 9391c0d..65d4272 100644 --- a/src/main/java/io/v/nutz/zhgh/mobile/healthCheckup/MHealthCheckupListController.java +++ b/src/main/java/io/v/nutz/zhgh/mobile/healthCheckup/MHealthCheckupListController.java @@ -5,14 +5,16 @@ import cn.hutool.core.util.StrUtil; import cn.wizzer.framework.base.Result; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.page.Pagination; +import io.v.nutz.base.query.PageForm; import io.v.nutz.base.service.BaseService; +import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupCampus; import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupProject; import io.v.nutz.zhgh.healthCheckup.model.HealthCheckupUserSelection; import io.v.nutz.zhgh.healthCheckup.service.HealthCheckupProjectService; -import io.v.nutz.base.query.PageForm; -import io.v.nutz.web.commons.utils.ShiroUtil; +import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; import org.nutz.dao.Sqls; import org.nutz.dao.sql.Sql; import org.nutz.ioc.loader.annotation.Inject; @@ -31,25 +33,25 @@ import java.util.Date; @At("/mobile/healthCheckup") public class MHealthCheckupListController { + @Inject + private Dao dao; @Inject private BaseService baseService; - @Inject private HealthCheckupProjectService healthCheckupProjectService; @At("/list") + @RequiresAuthentication @Ok("beetl:/mobile/healthCheckup/list.html") - public void index() { - - } + public void index() {} @At("/checkUp") + @RequiresAuthentication @Ok("beetl:/mobile/healthCheckup/checkUp.html") - public void checkUp() { - - } + public void checkUp() {} @At("/mine") + @RequiresAuthentication @Ok("beetl:/mobile/healthCheckup/mine.html") public void mine() { @@ -57,16 +59,29 @@ public class MHealthCheckupListController { @At @ViReturn + @RequiresAuthentication public Object pageData(PageForm pageForm, @Param(value = "tabName", required = false) String tabName) { +// Sql sql = Sqls.create(""" +// select +// p.*, +// (select count(*) from health_checkup_user_selection s where s.projectId=p.id and s.selectUserId=@userId) as selectCount +// from +// health_checkup_project p +// LEFT JOIN health_checkup_user hcu on hcu.projectId = p.id +// $condition +// """).setParam("userId", ShiroUtil.getUserId()); + Sql sql = Sqls.create(""" - select - p.*, - (select count(*) from health_checkup_user_selection s where s.projectId=p.id and s.selectUserId=@userId) as selectCount - from - health_checkup_project p - LEFT JOIN health_checkup_user hcu on hcu.projectId = p.id + SELECT + p.*, + sum(IF(hs.id is not null,1,0)) AS selectCount, + hs.id AS selectId + FROM + health_checkup_project p + LEFT JOIN health_checkup_user hcu ON hcu.projectId = p.id + LEFT JOIN health_checkup_user_selection hs ON hs.selectUserId = hcu.userId $condition - """).setParam("userId", ShiroUtil.getUserId()); + """); Cnd cnd = Cnd.NEW(); cnd.and("hcu.userId", "=", ShiroUtil.getUserId()); if ("ing".equals(tabName)) { @@ -74,6 +89,7 @@ public class MHealthCheckupListController { } else if ("end".equals(tabName)) { cnd.and("p.choiceTimeEnd", "<", DateUtil.now()); } + cnd.groupBy("p.id"); cnd.asc("selectCount"); sql.setCondition(cnd); Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); @@ -82,6 +98,7 @@ public class MHealthCheckupListController { @At @ViReturn + @RequiresAuthentication public Object mineData(PageForm pageForm, @Param(value = "tabName", required = false) String tabName) { Sql sql = Sqls.create(""" SELECT @@ -109,6 +126,7 @@ public class MHealthCheckupListController { @At @ViReturn + @RequiresAuthentication public Object doSubmit(@Param("userSelection") HealthCheckupUserSelection userSelection) { Trans.exec(() -> { if (userSelection.getId() == null) { @@ -126,6 +144,7 @@ public class MHealthCheckupListController { @At @ViReturn + @RequiresAuthentication public Object cancel(String id, String projectId) { HealthCheckupProject checkupProject = baseService.dao().fetch(HealthCheckupProject.class, projectId); if (DateUtil.compare(new Date(), checkupProject.getChoiceTimeEnd()) > 0) { @@ -141,6 +160,7 @@ public class MHealthCheckupListController { @At @ViReturn + @RequiresAuthentication public Object getSelectInfo(String id) { HealthCheckupUserSelection selection = baseService.dao().fetch(HealthCheckupUserSelection.class, id); baseService.dao().fetchLinks(selection, "companionList"); @@ -155,12 +175,14 @@ public class MHealthCheckupListController { @At @ViReturn + @RequiresAuthentication public Object getCampus() { return baseService.dao().query(HealthCheckupCampus.class, Cnd.NEW().asc("campusCode")); } @At @ViReturn + @RequiresAuthentication public Object validCondition(String cndId) { if (StrUtil.isBlank(cndId)) { return Result.success(); @@ -171,4 +193,26 @@ public class MHealthCheckupListController { } return null; } + + + @At + @ViReturn + @RequiresAuthentication + public Object getUserInfo(){ + Sql sql = Sqls.create(""" + SELECT + loginname, + username, + sex, + mobile, + idcard, + TIMESTAMPDIFF(YEAR, STR_TO_DATE(SUBSTRING(idcard, 7, 8), '%Y%m%d'), CURDATE()) AS age + FROM + sys_user + WHERE id = @userId + """).setParam("userId", ShiroUtil.getUserId()); + sql.setCallback(Sqls.callback.map()); + dao.execute(sql); + return sql.getResult(); + } } diff --git a/src/main/resources/views/mobile/healthCheckup/checkUp.html b/src/main/resources/views/mobile/healthCheckup/checkUp.html index bf2f65c..f1a8575 100644 --- a/src/main/resources/views/mobile/healthCheckup/checkUp.html +++ b/src/main/resources/views/mobile/healthCheckup/checkUp.html @@ -122,7 +122,7 @@ layout("/mobile/platform.html"){