+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.controller;
+
+import com.elink.esua.epdc.commons.tools.enums.BehaviorEnum;
+import com.elink.esua.epdc.commons.tools.page.PageData;
+import com.elink.esua.epdc.commons.tools.utils.Result;
+import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
+import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
+import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
+import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
+import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
+import com.elink.esua.epdc.dto.UserSignDTO;
+import com.elink.esua.epdc.pointcommons.tools.annotation.RecordUserBehavior;
+import com.elink.esua.epdc.service.UserService;
+import com.elink.esua.epdc.service.UserSignService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+
+/**
+ * 用户签到表
+ *
+ * @author qu qu@elink-cn.com
+ * @since v1.0.0 2020-07-21
+ */
+@RestController
+@RequestMapping("usersign")
+public class UserSignController {
+
+ @Autowired
+ private UserSignService userSignService;
+
+ @Autowired
+ private UserService userService;
+
+ @GetMapping("page")
+ public Result> page(@RequestParam Map params){
+ PageData page = userSignService.page(params);
+ return new Result>().ok(page);
+ }
+
+ @GetMapping("{id}")
+ public Result get(@PathVariable("id") String id){
+ UserSignDTO data = userSignService.get(id);
+ return new Result().ok(data);
+ }
+
+ @PostMapping
+ public Result save(@RequestBody UserSignDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+ userSignService.save(dto);
+ return new Result();
+ }
+
+ @PutMapping
+ public Result update(@RequestBody UserSignDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
+ userSignService.update(dto);
+ return new Result();
+ }
+
+ @DeleteMapping
+ public Result delete(@RequestBody String[] ids){
+ //效验数据
+ AssertUtils.isArrayEmpty(ids, "id");
+ userSignService.delete(ids);
+ return new Result();
+ }
+
+ /**
+ * @Description 根据用户ID获取用户签到信息
+ * @Author zy
+ * @Date 2020/7/21
+ * @Param [userId]
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ **/
+ @GetMapping("getUserSignInfoByUserId/{userId}")
+ public Result getUserSignInfoByUserId(@PathVariable("userId") String userId){
+ return new Result().ok(userSignService.getUserSignInfoByUserId(userId));
+ }
+ /**
+ * @Description 更新或新增签到时间和连续签到次数
+ * @Author zy
+ * @Date 2020/7/21
+ * @Param [userSignDTO]
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ **/
+ @GetMapping("saveOrUpdateSignById")
+ public Result saveOrUpdateSignById(@RequestBody UserSignDTO userSignDTO){
+ return userSignService.saveOrUpdateSignById(userSignDTO);
+ }
+
+ /**
+ * @Description 签到加积分操作
+ * @Author zy
+ * @Date 2020/7/21
+ * @Param [userSignDTO]
+ **/
+ @GetMapping("addSignPoints")
+ @RecordUserBehavior(behavior = BehaviorEnum.USER_SIGN,referenceId = "#{userSignDTO.getId}",userId = "#{userSignDTO.getUserId}",gridId = "#{userSignDTO.getGridId}")
+ public Result addSignPoints(@RequestBody UserSignDTO userSignDTO){
+ Result userGridIdByUserId = userService.getUserGridIdByUserId(userSignDTO.getUserId());
+ userSignDTO.setGridId(userGridIdByUserId.getData());
+ return new Result();
+ }
+ /**
+ * @Description 连续签到加积分
+ * @Author zy
+ * @Date 2020/7/21
+ * @Param [userSignDTO]
+ **/
+ @GetMapping("addConsequentSignPoints")
+ @RecordUserBehavior(behavior = BehaviorEnum.USER_CONSEQUENT_SIGN,referenceId = "#{userSignDTO.getId}",userId = "#{userSignDTO.getUserId}",gridId = "#{userSignDTO.getGridId}")
+ public Result addConsequentSignPoints(@RequestBody UserSignDTO userSignDTO){
+ Result userGridIdByUserId = userService.getUserGridIdByUserId(userSignDTO.getUserId());
+ userSignDTO.setGridId(userGridIdByUserId.getData());
+ return new Result();
+ }
+}
diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserDao.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserDao.java
index c0e86e1..2ac1b7d 100644
--- a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserDao.java
+++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserDao.java
@@ -329,4 +329,13 @@ public interface UserDao extends BaseDao {
* @return java.util.List
*/
List getUserListForVolunteerOrg(Map params);
+
+ /**
+ * @Description 获取用户绑定网格接口 - 未绑定 获取第一次扫码网格
+ * @Author zy
+ * @Date 2020/12/14
+ * @Param [userId]
+ * @return java.lang.Long
+ **/
+ Long getUserGridIdByUserId(@Param("userId") String userId);
}
diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserSignDao.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserSignDao.java
new file mode 100644
index 0000000..422884a
--- /dev/null
+++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/dao/UserSignDao.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.dao;
+
+import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
+import com.elink.esua.epdc.dto.UserSignDTO;
+import com.elink.esua.epdc.entity.UserSignEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 用户签到表
+ *
+ * @author qu qu@elink-cn.com
+ * @since v1.0.0 2020-07-21
+ */
+@Mapper
+public interface UserSignDao extends BaseDao {
+ /**
+ * @Description 根据用户ID获取用户签到信息
+ * @Author zy
+ * @Date 2020/7/21
+ * @Param [userId]
+ * @return com.elink.esua.epdc.dto.UserSignDTO
+ **/
+ UserSignDTO selectUserSignInfoByUserId(String userId);
+}
diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/entity/UserSignEntity.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/entity/UserSignEntity.java
new file mode 100644
index 0000000..c0ddd54
--- /dev/null
+++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/entity/UserSignEntity.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 用户签到表
+ *
+ * @author qu qu@elink-cn.com
+ * @since v1.0.0 2020-07-21
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("epdc_user_sign")
+public class UserSignEntity extends BaseEpdcEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 用户ID
+ */
+ private String userId;
+
+ /**
+ * 连续签到天数
+ */
+ private Integer consequentSignDays;
+
+ /**
+ * 最近签到时间
+ */
+ private Date lastSignTime;
+
+}
diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserService.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserService.java
index a4d2c68..4cdc426 100644
--- a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserService.java
+++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserService.java
@@ -467,4 +467,13 @@ public interface UserService extends BaseService {
* @return com.elink.esua.epdc.commons.tools.utils.Result
*/
PageData getUserListForVolunteerOrg(Map params);
+
+ /**
+ * @Description 获取用户绑定网格接口 - 未绑定 获取第一次扫码网格
+ * @Author zy
+ * @Date 2020/12/14
+ * @Param [userId]
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ **/
+ Result getUserGridIdByUserId(String userId);
}
diff --git a/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserSignService.java b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserSignService.java
new file mode 100644
index 0000000..57445a4
--- /dev/null
+++ b/epdc-cloud-user/src/main/java/com/elink/esua/epdc/service/UserSignService.java
@@ -0,0 +1,112 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
+import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
+import com.elink.esua.epdc.commons.tools.page.PageData;
+import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
+import com.elink.esua.epdc.commons.tools.utils.Result;
+import com.elink.esua.epdc.dao.UserSignDao;
+import com.elink.esua.epdc.dto.UserSignDTO;
+import com.elink.esua.epdc.entity.UserSignEntity;
+import com.elink.esua.epdc.service.UserSignService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 用户签到表
+ *
+ * @author qu qu@elink-cn.com
+ * @since v1.0.0 2020-07-21
+ */
+@Service
+public class UserSignServiceImpl extends BaseServiceImpl implements UserSignService {
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, FieldConstant.CREATED_TIME, false),
+ getWrapper(params)
+ );
+ return getPageData(page, UserSignDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, UserSignDTO.class);
+ }
+
+ private QueryWrapper getWrapper(Map params){
+ String id = (String)params.get(FieldConstant.ID_HUMP);
+
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
+
+ return wrapper;
+ }
+
+ @Override
+ public UserSignDTO get(String id) {
+ UserSignEntity entity = baseDao.selectById(id);
+ return ConvertUtils.sourceToTarget(entity, UserSignDTO.class);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void save(UserSignDTO dto) {
+ UserSignEntity entity = ConvertUtils.sourceToTarget(dto, UserSignEntity.class);
+ insert(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(UserSignDTO dto) {
+ UserSignEntity entity = ConvertUtils.sourceToTarget(dto, UserSignEntity.class);
+ updateById(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delete(String[] ids) {
+ // 逻辑删除(@TableLogic 注解)
+ baseDao.deleteBatchIds(Arrays.asList(ids));
+ }
+
+ @Override
+ public UserSignDTO getUserSignInfoByUserId(String userId) {
+ return baseDao.selectUserSignInfoByUserId(userId);
+ }
+
+ @Override
+ public Result saveOrUpdateSignById(UserSignDTO userSignDTO) {
+ UserSignEntity entity = ConvertUtils.sourceToTarget(userSignDTO, UserSignEntity.class);
+ if(StringUtils.isNotBlank(entity.getId())){
+ updateById(entity);
+ return new Result();
+ } else {
+ insert(entity);
+ return new Result().ok(entity.getId());
+ }
+ }
+
+}
diff --git a/epdc-cloud-user/src/main/resources/mapper/UserDao.xml b/epdc-cloud-user/src/main/resources/mapper/UserDao.xml
index 1c0acd4..9ee07aa 100644
--- a/epdc-cloud-user/src/main/resources/mapper/UserDao.xml
+++ b/epdc-cloud-user/src/main/resources/mapper/UserDao.xml
@@ -33,14 +33,15 @@
COUNT( ui.ID )
WHEN 0 THEN
'0' ELSE '1'
- END AS showIdentityFlag
+ END AS showIdentityFlag,
+ date_format(eus.LAST_SIGN_TIME,'%Y-%m-%d') = CURDATE() as isSignUp
FROM
epdc_user eu
- LEFT JOIN ( SELECT gr.ALL_DEPT_NAMES, gr.USER_ID FROM epdc_user_grid_relation gr WHERE gr.DEL_FLAG = '0' AND gr.USER_ID = #{id} ORDER BY gr.UPDATED_TIME DESC LIMIT 0, 1 ) eugr ON ( eu.id = eugr.USER_ID )
- LEFT JOIN epdc_user_info ui ON eu.ID = ui.USER_ID
- AND ui.DEL_FLAG = '0'
- left join epdc_points_grade g ON 1=1 AND g.DEL_FLAG = 0
+ LEFT JOIN ( SELECT gr.ALL_DEPT_NAMES, gr.USER_ID FROM epdc_user_grid_relation gr WHERE gr.DEL_FLAG = '0' AND gr.USER_ID = #{id} ORDER BY gr.UPDATED_TIME DESC LIMIT 0, 1 ) eugr ON ( eu.id = eugr.USER_ID )
+ LEFT JOIN epdc_user_info ui ON eu.ID = ui.USER_ID AND ui.DEL_FLAG = '0'
+ LEFT JOIN epdc_points_grade g ON 1=1 AND g.DEL_FLAG = 0
LEFT JOIN epdc_volunteer_info v ON eu.ID = v.USER_ID
+ LEFT JOIN epdc_user_sign eus on eus.USER_ID = eu.ID and eus.DEL_FLAG = '0'
WHERE
eu.ID = #{id}
AND eu.DEL_FLAG = '0'
@@ -974,4 +975,13 @@ WHERE 1 = 1
ORDER BY
points DESC
+
+
+
diff --git a/epdc-cloud-user/src/main/resources/mapper/UserSignDao.xml b/epdc-cloud-user/src/main/resources/mapper/UserSignDao.xml
new file mode 100644
index 0000000..4110257
--- /dev/null
+++ b/epdc-cloud-user/src/main/resources/mapper/UserSignDao.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file