| @@ -13,6 +13,7 @@ import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * (ComputingResource)表控制层 | * (ComputingResource)表控制层 | ||||
| @@ -104,5 +105,11 @@ public class ComputingResourceController extends BaseController { | |||||
| PageRequest pageRequest = PageRequest.of(page, size); | PageRequest pageRequest = PageRequest.of(page, size); | ||||
| return genericsSuccess(resourceOccupyService.queryByPage(pageRequest)); | return genericsSuccess(resourceOccupyService.queryByPage(pageRequest)); | ||||
| } | } | ||||
| @GetMapping("/credit") | |||||
| @ApiOperation("查询用户积分使用情况") | |||||
| public GenericsAjaxResult<Map<String, Integer>> queryCredit() { | |||||
| return genericsSuccess(resourceOccupyService.queryCredit()); | |||||
| } | |||||
| } | } | ||||
| @@ -22,7 +22,11 @@ public interface ResourceOccupyDao { | |||||
| int updateUnUsed(@Param("id") Integer id, @Param("used") Integer used); | int updateUnUsed(@Param("id") Integer id, @Param("used") Integer used); | ||||
| long count(); | |||||
| long count(@Param("userId") Long userId); | |||||
| List<ResourceOccupy> queryByPage(@Param("pageable") Pageable pageable); | |||||
| List<ResourceOccupy> queryByPage(@Param("userId") Long userId, @Param("pageable") Pageable pageable); | |||||
| Integer getUserCredit(@Param("userId") Long userId); | |||||
| Integer getDeduceCredit(@Param("userId") Long userId); | |||||
| } | } | ||||
| @@ -5,6 +5,7 @@ import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | import org.springframework.data.domain.PageRequest; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Map; | |||||
| public interface ResourceOccupyService { | public interface ResourceOccupyService { | ||||
| @@ -17,4 +18,6 @@ public interface ResourceOccupyService { | |||||
| void deducing(String taskType, Long taskId, String nodeId, Date nodeStartTime); | void deducing(String taskType, Long taskId, String nodeId, Date nodeStartTime); | ||||
| Page<ResourceOccupy> queryByPage(PageRequest pageRequest); | Page<ResourceOccupy> queryByPage(PageRequest pageRequest); | ||||
| Map<String, Integer> queryCredit(); | |||||
| } | } | ||||
| @@ -16,7 +16,9 @@ import org.springframework.transaction.annotation.Transactional; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| @Service("resourceOccupyService") | @Service("resourceOccupyService") | ||||
| public class ResourceOccupyServiceImpl implements ResourceOccupyService { | public class ResourceOccupyServiceImpl implements ResourceOccupyService { | ||||
| @@ -113,7 +115,17 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService { | |||||
| @Override | @Override | ||||
| public Page<ResourceOccupy> queryByPage(PageRequest pageRequest) { | public Page<ResourceOccupy> queryByPage(PageRequest pageRequest) { | ||||
| long total = resourceOccupyDao.count(); | |||||
| return new PageImpl<>(resourceOccupyDao.queryByPage(pageRequest), pageRequest, total); | |||||
| long total = resourceOccupyDao.count(SecurityUtils.getLoginUser().getUserid()); | |||||
| return new PageImpl<>(resourceOccupyDao.queryByPage(SecurityUtils.getLoginUser().getUserid(), pageRequest), pageRequest, total); | |||||
| } | |||||
| @Override | |||||
| public Map<String, Integer> queryCredit() { | |||||
| Integer userCredit = resourceOccupyDao.getUserCredit(SecurityUtils.getLoginUser().getUserid()); | |||||
| Integer deduceCredit = resourceOccupyDao.getDeduceCredit(SecurityUtils.getLoginUser().getUserid()); | |||||
| HashMap<String, Integer> result = new HashMap<>(); | |||||
| result.put("userCredit", userCredit); | |||||
| result.put("deduceCredit", deduceCredit); | |||||
| return result; | |||||
| } | } | ||||
| } | } | ||||
| @@ -53,20 +53,41 @@ | |||||
| select * | select * | ||||
| from resource_occupy | from resource_occupy | ||||
| where task_type = #{taskType} | where task_type = #{taskType} | ||||
| and task_id = #{taskId} | |||||
| and task_id = #{taskId} | |||||
| <if test="nodeId != null and nodeId !=''"> | <if test="nodeId != null and nodeId !=''"> | ||||
| and node_id = #{nodeId} | and node_id = #{nodeId} | ||||
| </if> | </if> | ||||
| and state = 1 | |||||
| and state = 1 | |||||
| </select> | </select> | ||||
| <select id="count" resultType="java.lang.Long"> | <select id="count" resultType="java.lang.Long"> | ||||
| select count(1) from resource_occupy | |||||
| select count(1) | |||||
| from resource_occupy | |||||
| where user_id = #{userId} | |||||
| </select> | </select> | ||||
| <select id="queryByPage" resultType="com.ruoyi.platform.domain.ResourceOccupy"> | <select id="queryByPage" resultType="com.ruoyi.platform.domain.ResourceOccupy"> | ||||
| select * | |||||
| select id, | |||||
| user_id, | |||||
| description, | |||||
| credit_per_hour, | |||||
| TRUNCATE(deduce_credit, 1) as deduce_credit, | |||||
| start_time, | |||||
| state | |||||
| from resource_occupy | from resource_occupy | ||||
| where user_id = #{userId} | |||||
| order by start_time desc limit #{pageable.offset}, #{pageable.pageSize} | order by start_time desc limit #{pageable.offset}, #{pageable.pageSize} | ||||
| </select> | </select> | ||||
| <select id="getUserCredit" resultType="java.lang.Integer"> | |||||
| select TRUNCATE(credit, 1) as credit | |||||
| from sys_user | |||||
| where user_id = #{userId} | |||||
| </select> | |||||
| <select id="getDeduceCredit" resultType="java.lang.Integer"> | |||||
| select TRUNCATE(sum(deduce_credit), 1) as deduce_credit | |||||
| from resource_occupy | |||||
| where user_id = #{userId} | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -60,7 +60,7 @@ | |||||
| u.password, | u.password, | ||||
| u.git_link_username, | u.git_link_username, | ||||
| u.git_link_password, | u.git_link_password, | ||||
| u.credit, | |||||
| TRUNCATE(u.credit, 1) as credit, | |||||
| u.sex, | u.sex, | ||||
| u.status, | u.status, | ||||
| u.del_flag, | u.del_flag, | ||||
| @@ -90,7 +90,7 @@ | |||||
| <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> | <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> | ||||
| select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, | select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, | ||||
| u.git_link_username, u.credit, | |||||
| u.git_link_username, TRUNCATE(u.credit, 1) as credit, | |||||
| u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader | u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader | ||||
| from sys_user u | from sys_user u | ||||
| left join sys_dept d on u.dept_id = d.dept_id | left join sys_dept d on u.dept_id = d.dept_id | ||||
| @@ -125,7 +125,7 @@ | |||||
| </select> | </select> | ||||
| <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult"> | <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult"> | ||||
| select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time, u.credit, u.git_link_username | |||||
| select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time, TRUNCATE(u.credit, 1) as credit, u.git_link_username | |||||
| from sys_user u | from sys_user u | ||||
| left join sys_dept d on u.dept_id = d.dept_id | left join sys_dept d on u.dept_id = d.dept_id | ||||
| left join sys_user_role ur on u.user_id = ur.user_id | left join sys_user_role ur on u.user_id = ur.user_id | ||||
| @@ -142,7 +142,7 @@ | |||||
| </select> | </select> | ||||
| <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult"> | <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult"> | ||||
| select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time , u.credit, u.git_link_username | |||||
| select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time , TRUNCATE(u.credit, 1) as credit, u.git_link_username | |||||
| from sys_user u | from sys_user u | ||||
| left join sys_dept d on u.dept_id = d.dept_id | left join sys_dept d on u.dept_id = d.dept_id | ||||
| left join sys_user_role ur on u.user_id = ur.user_id | left join sys_user_role ur on u.user_id = ur.user_id | ||||